<?php

namespace Home\Controller;

/**
 * 预订设置相关页面视图
 *
 * @author AmosZhong
 * @date 2016-04-27
 */
class BookSettingPageController extends ParentController {

    protected function _initialize() {
        parent::_initialize();
        $hotelBookLogic = A('Common/HotelBook', 'Logic');
        $hotelDetail = $hotelBookLogic->getInfo($this->hotelId);
        $hotelPreviewDetail = array('name' => $hotelDetail['name'], 'desc' => $hotelDetail['description']);        
        $this->assign('logoimageurl', empty($hotelDetail['logoimageurl'])?'/Public/uclbrt/image/meizhu.png':$hotelDetail['logoimageurl']);
        $this->assign('hotelPreviewDetail', $hotelPreviewDetail);
        $this->assign('hotelShareStatus', $hotelDetail['sharekey']);
    }

    /**
     * 优惠券设置页面视图
     *
     * @author wenhui
     * @date 2018-01-12
     */
    public function coupon() {
        $hotelId = $this->hotelId;

        // 检查客栈是否已过期
        $hotelLogic = A('Common/Hotel', 'Logic');
        $result = $hotelLogic->checkHotelActive($hotelId);
        if ($result == false) {
            return;
        }

        // 校验是否已经开通
        $hotelBookLogic = A('Common/HotelBook', 'Logic');
        $isEnable = $hotelBookLogic->checkEnable($hotelId);
        if (!$isEnable) {
            returnJson(403, 409);
            return;
        }

        $roomTypeBookLogic = A('Common/RoomTypeBook', 'Logic');
        $roomTypeInfo = $roomTypeBookLogic->getInfo($hotelId);

        // 处理数据
        $roomTypeData = array();
        foreach ($roomTypeInfo as $roomTypeInfoItem) {
            $roomTypeData[] = array(
                'id' => $roomTypeInfoItem['id'],
                'name' => $roomTypeInfoItem['name'],
            );
        }
        unset($roomTypeInfoItem);

        $this->assign('roomTypeData', $roomTypeData);
        $this->display();
    }

}
        